void GetClassInf(System* pc)
{
	System class1;//一班的数据
	System class2;//二班的数据
	System class3;//三班的数据
	InitSystem(&class1);
	InitSystem(&class2);
	InitSystem(&class3);

	int num1 = 0;
	int num2 = 0;
	int num3 = 0;
	for (int i = 0; i < pc->sz; i++)
	{
		if ((pc->data + i)->num[10] == '0')
		{
			check_capacity(&class1);
			strcpy(class1.data[num1].num, (pc->data + i)->num); //c语言没重载不能直接赋值
			strcpy(class1.data[num1].name, (pc->data + i)->name);
			class1.data[num1].math = (pc->data + i)->math;
			class1.data[num1].la = (pc->data + i)->la;
			class1.data[num1].english = (pc->data + i)->english;
			class1.data[num1].ds = (pc->data + i)->ds;
			class1.data[num1].pe = (pc->data + i)->pe;
			class1.data[num1].math2 = (pc->data + i)->math2;
			class1.data[num1].ave = (pc->data + i)->ave;
			class1.data[num1].sum = (pc->data + i)->sum;
			class1.sz++;//容量增加
			num1++;
		}

		if ((pc->data + i)->num[10] == '1')
		{
			check_capacity(&class2);
			strcpy(class2.data[num2].num, (pc->data + i)->num); //c语言没重载不能直接赋值
			strcpy(class2.data[num2].name, (pc->data + i)->name);
			class2.data[num2].math = (pc->data + i)->math;
			class2.data[num2].la = (pc->data + i)->la;
			class2.data[num2].english = (pc->data + i)->english;
			class2.data[num2].ds = (pc->data + i)->ds;
			class2.data[num2].pe = (pc->data + i)->pe;
			class2.data[num2].math2 = (pc->data + i)->math2;
			class2.data[num2].ave = (pc->data + i)->ave;
			class2.data[num2].sum = (pc->data + i)->sum;
			class2.sz++;//容量增加
			num2++;
		}

		if ((pc->data + i)->num[10] == '2')
		{
			check_capacity(&class3);
			strcpy(class3.data[num3].num, (pc->data + i)->num); //c语言没重载不能直接赋值
			strcpy(class3.data[num3].name, (pc->data + i)->name);
			class3.data[num3].math = (pc->data + i)->math;
			class3.data[num3].la = (pc->data + i)->la;
			class3.data[num3].english = (pc->data + i)->english;
			class3.data[num3].ds = (pc->data + i)->ds;
			class3.data[num3].pe = (pc->data + i)->pe;
			class3.data[num3].math2 = (pc->data + i)->math2;
			class3.data[num3].ave = (pc->data + i)->ave;
			class3.data[num3].sum = (pc->data + i)->sum;
			class3.sz++;//容量增加
			num3++;
		}

	}
	

	vector<pair<string, double>> high;//0高数 1线性代数 2英语 3数据结构 4体育 5离散
	vector<pair<string, double>> low;
	double sum=0;
	GetHighAndLow(&class1, high, low, sum);

	//写1班
	FILE* pf = fopen("一班各科信息.txt", "w");
	if (NULL == pf)//报错无文件
	{
		perror("SaveSystem");
	}
	else
	{
		PrintInfo(pf, &class1, high, low, sum, 1);
	}

	high.clear();
	low.clear();
	sum=0;
	GetHighAndLow(&class2, high, low, sum);
	//写2班
	pf = fopen("二班各科信息.txt", "w");
	if (NULL == pf)//报错无文件
	{
		perror("SaveSystem");
	}
	else
	{
		PrintInfo(pf, &class2, high, low, sum, 2);
	}

	//写3班
	pf = fopen("三班各科信息.txt", "w");
	if (NULL == pf)//报错无文件
	{
		perror("SaveSystem");
	}
	else
	{
		PrintInfo(pf, &class3, high, low, sum, 3);
	}

	system("start 一班各科信息.txt");
	system("start 二班各科信息.txt");
	system("start 三班各科信息.txt");
	system("cls");

}


//打印相应班级的各种信息
void PrintInfo(FILE* pf, System* class1, vector<pair<string, double>>& high, vector<pair<string, double>>& low, double sum,int num)
{
	if (class1->sz == 0)
	{
		fprintf(pf, "您未导入该班成绩\n");
	}
	else
	{
		fprintf(pf, "--------------------------------------------------------------------------------------------------------------\n");
		fprintf(pf, "%d班成绩信息:\n",num);
		fprintf(pf, "共 %d 人参加考试\n", class1->sz);
		fprintf(pf, "缺考人数为:0\n\n");
		fprintf(pf, "平均分为: %.1lf\n", (sum / class1->sz));
		fprintf(pf, "科目         最高分名字           最高分       最低分名字            最低分       \n");
		fprintf(pf, "高数         %s               %.1lf        %s                %.1lf        \n", high[0].first.data(), high[0].second, low[0].first.data(), low[0].second);
		fprintf(pf, "线代         %s               %.1lf        %s                %.1lf        \n", high[1].first.data(), high[1].second, low[1].first.data(), low[1].second);
		fprintf(pf, "英语         %s               %.1lf        %s                %.1lf        \n", high[2].first.data(), high[2].second, low[2].first.data(), low[2].second);
		fprintf(pf, "数据结构     %s               %.1lf        %s                %.1lf        \n", high[3].first.data(), high[3].second, low[3].first.data(), low[3].second);
		fprintf(pf, "体育         %s               %.1lf        %s                %.1lf        \n", high[4].first.data(), high[4].second, low[4].first.data(), low[4].second);
		fprintf(pf, "离散         %s               %.1lf        %s                %.1lf        \n", high[5].first.data(), high[5].second, low[5].first.data(), low[5].second);
		fprintf(pf, "--------------------------------------------------------------------------------------------------------------\n");



		fclose(pf);
		pf = NULL;
	}
}


//获取最高分和最低分
void GetHighAndLow(System* class1, vector<pair<string, double>>& high, vector<pair<string, double>>& low, double& sum)
{
	for (int i = 0; i < class1->sz; i++)
	{
		if (i == 0)
		{
			sum += class1->data[i].sum;
			high.push_back(make_pair(string(class1->data[i].name), class1->data[i].math));
			high.push_back(make_pair(string(class1->data[i].name), class1->data[i].la));
			high.push_back(make_pair(string(class1->data[i].name), class1->data[i].english));
			high.push_back(make_pair(string(class1->data[i].name), class1->data[i].ds));
			high.push_back(make_pair(string(class1->data[i].name), class1->data[i].pe));
			high.push_back(make_pair(string(class1->data[i].name), class1->data[i].math2));

			low.push_back(make_pair(string(class1->data[i].name), class1->data[i].math));
			low.push_back(make_pair(string(class1->data[i].name), class1->data[i].la));
			low.push_back(make_pair(string(class1->data[i].name), class1->data[i].english));
			low.push_back(make_pair(string(class1->data[i].name), class1->data[i].ds));
			low.push_back(make_pair(string(class1->data[i].name), class1->data[i].pe));
			low.push_back(make_pair(string(class1->data[i].name), class1->data[i].math2));

			continue;
		}
		else
		{
			sum += class1->data[i].sum;
			if (class1->data[i].math > high[0].second)
			{
				high[0]=(make_pair(string(class1->data[i].name), class1->data[i].math));
			}
			if (class1->data[i].la > high[1].second)
			{
				high[1]=(make_pair(string(class1->data[i].name), class1->data[i].la));
			}
			if (class1->data[i].english > high[2].second)
			{
				high[2]=(make_pair(string(class1->data[i].name), class1->data[i].english));
			}
			if (class1->data[i].ds > high[3].second)
			{
				high[3]=(make_pair(string(class1->data[i].name), class1->data[i].ds));
			}
			if (class1->data[i].pe > high[4].second)
			{
				high[4]=(make_pair(string(class1->data[i].name), class1->data[i].ds));
			}
			if (class1->data[i].math2 > high[5].second)
			{
				high[5]=(make_pair(string(class1->data[i].name), class1->data[i].math2));
			}


			if (class1->data[i].math < low[0].second)
			{
				low[0]=(make_pair(string(class1->data[i].name), class1->data[i].math));
			}
			if (class1->data[i].la < low[1].second)
			{
				low[1]=(make_pair(string(class1->data[i].name), class1->data[i].la));
			}
			if (class1->data[i].english < low[2].second)
			{
				low[2]=(make_pair(string(class1->data[i].name), class1->data[i].english));
			}
			if (class1->data[i].ds < low[3].second)
			{
				low[3]=(make_pair(string(class1->data[i].name), class1->data[i].ds));
			}
			if (class1->data[i].pe < low[4].second)
			{
				low[4]=(make_pair(string(class1->data[i].name), class1->data[i].ds));
			}
			if (class1->data[i].math2 < low[5].second)
			{
				low[5]=(make_pair(string(class1->data[i].name), class1->data[i].math2));
			}

		}
	}
}